#!/usr/bin/Rscript

## http://addictedtor.free.fr/graphiques/graphcode.php?graph=3

## set.seed(22)              #just so you have exactly the same graph as the gallery's
## x <- rnorm(50)
## plot(x, ann=FALSE, type="n")
## abline(h=0, col=gray(.90))
## lines(x, col="green4", lty="dotted")
## points(x, bg="limegreen", pch=21)
## title(main="Simple Use of Color In a Plot",
##       xlab="Just a Whisper of a Label",
##       col.main="blue", col.lab=gray(.8),
##       cex.main=1.2, cex.lab=1.0, font.main=4, font.lab=3)

args <- commandArgs()
filename = args[6]
m = read.csv(filename, header=TRUE)
m = data.frame(scale(m, center=FALSE, scale = c(60, 1024^2, 1024^2, 1)))
mRSS = m[,c("time", "RSS")]
mVSZ = m[,c("time", "VSZ")]
mPERCENT = m[,c("time", "X.MEM")]
pdf(file=paste(strsplit(filename, "\\.")[[1]][1],".pdf", sep=""))
plot(mRSS, col="red", type='l', xlab="time (min)", ylim=c(0,max(mRSS[,2], mVSZ[,2])), ylab="memory (GB)")
lines(mVSZ, col="royalblue", type='l')
legend(x="bottomright", legend=c("RSS (resident set size)","VSZ (virtual memory size)"), col=c("red","royalblue"), pch=c('-', '-'), lty=c(1,1));
#plot(mPERCENT)
dev.off()
